<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/tentime"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <title>新增</title>
    <script th:replace="/common/template :: common"></script>
	<script type="text/javascript" th:inline="javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function(form){
					$("#inputForm").ajaxSubmit({
						type : "post"
			            ,url : ctx + '/buz/committee/save'
			            ,success : function(data) {
			            	var code = data.code;
			            	if (code == 200) {
			            		parent.layer.msg('数据保存成功!', {icon: 1});
			            	} else {
			            		parent.layer.msg('数据验证失败!', {icon: 2});
			            	}
			            }
					});
				}
			});
		});
		/*
		function closeWin() {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }
		*/
		function getUser(multi) { // multi = 0 单选；multi=1 多选
			var url = ctx + '/common/userSelect?multi=' + multi;
			//openTopWin("选择用户", url, 750, 450);
			parent.layer.open({
	       	  type: 2 //此处以iframe举例
	       	  ,title: '选择员工'
	       	  ,area: ['750px', '450px'] //宽高自适应
	       	  ,shade: 0.3
	       	  ,maxmin: true
	       	  ,content: url
	       	  ,datatype: "json"
	       	  ,btn: ['确定', '清除','关闭']
			  ,yes: function (index, layero) {
				  var datas = layero.find("iframe")[0].contentWindow.selectData();
				  if (datas.size() == 0) {
					  parent.layer.msg('请选择人员', {icon : 2});
					  return false;
				  } else {
					  var key = datas.keySet()[0];
					  var row = datas.get(key);
					  var userNo = row.username;
					  var userName = row.nickname;
					  console.log('*************' + userNo + '---nickname=' + userName);
					 $('#userNo').val(userNo);
					 $('#userName').val(userName);
					  parent.layer.close(index);
				  }   
			  }
			  ,btn2: function(index, layero){
				  $('#userNo').val('');
				  $('#userName').val('');
				  parent.layer.close(index);
			  }
			});
		}
		
		
	</script>
	
</head>
<body>
	  <form id="inputForm" th:object="${entity}">
		<input name="id" type="hidden">
		<table border="1" cellpadding="0" cellspacing="0" class="z_ghtzd3">
			<tr>
    		    <th nowrap="nowrap"><b>工号</b><label class="validate">*</label></th>
    			<td>
    				<input id="userNo" name="userNo" th:value="${userNo}" htmlEscape="false" size="12" class="required"/>
    				
					<button type="button" class="btn hideBtn" onclick="getUser('0');"><i class="icon-search"></i></button>
    				
    			</td>
    			<th nowrap="nowrap"><b>姓名</b><label class="validate">*</label></th>
    			<td><input id="userName" name="userName" th:value="${userName}" htmlEscape="false" size="12" class="required" cssStyle="width:150px;"/></td>
    		</tr>
			
    		<tr>
    		    <th nowrap="nowrap"><b>备注</b></th>
    			<td colspan="2">
    				<textarea name="remarks" htmlEscape="false" rows="5" cssStyle="width:400px;">[[${entity?.remarks}]]</textarea>
    			</td>
    			<td>
    				<button id="btnSubmit" class="btn btn-success" type="submit"><i class="icon-ok"></i>保 存</button>&nbsp;
                	<button id="btnCancel" class="btn btn-warning" type="button" onclick="closeWin();"><i class="icon-remove"></i>关 闭</button>
                </td>
    		</tr>
		</table>
	</form>
</body>
</html>